const path = require("path");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
// 导出配置
module.exports = {
  mode: "development", // 打包模式
  entry: "./src/main.js", // 入口文件
  // 打包后输出文件
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "my_uitools_v2.js",
    library: "my_uitools_v2",
    libraryTarget: "umd",
    umdNamedDefine: true,
  },
  target: ["web", "es5"], // 编译成 es5
  resolve: {
    extensions: [".js", ".jsx"],
    alias: {
      // 配置 import 相对路径引入的文件or图片
      "@": "/src",
      "#": "/Packages",
      "*": "/Tools",
    },
  },
  // 文件解析
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env"],
          },
        },
      },
      {
        test: /\.vue$/,
        loader: "vue-loader",
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        use: ["style-loader", "css-loader", "sass-loader"],
      },
    ],
  },
  plugins: [new VueLoaderPlugin()],
};
